package com.onenine.app.view.popwin;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;

import com.onenine.app.R;

/**
 * 创建时间：2018/3/27 0018 11:10
 * 创建人：fly
 * 功能描述：更换头像弹层
 */
public class AvatarPopWindow extends BottomPopWindow implements View.OnClickListener {

    private Callback mCallback;

    public interface Callback {
        void onViewAvatar();

        void onEditAvatar();
    }

    public AvatarPopWindow(Activity activity, Callback callback) {
        super(activity);
        mCallback = callback;
    }

    @Override
    public void onClick(View v) {
        dismiss();
        if (v.getId() == R.id.btn_view_img) {
            //浏览大图
            if (mCallback != null) {
                mCallback.onViewAvatar();
            }
        } else if (v.getId() == R.id.btn_edit_avatar) {
            //从相册选择
            if (mCallback != null) {
                mCallback.onEditAvatar();
            }
        }
    }

    @Override
    protected View genContentView() {
        View bottomView = LayoutInflater.from(mActivity)
                .inflate(R.layout.layout_avatar_popwin, null, false);
        bottomView.setOnClickListener(this);
        bottomView.findViewById(R.id.btn_view_img).setOnClickListener(this);
        bottomView.findViewById(R.id.btn_edit_avatar).setOnClickListener(this);
        bottomView.findViewById(R.id.btn_cancel).setOnClickListener(this);
        return bottomView;
    }

}
